package logic

import (
	"context"
	"jd-mall/jd/jdclient"

	"jd-mall/api/internal/svc"
	"jd-mall/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CarDelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCarDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CarDelLogic {
	return &CarDelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CarDelLogic) CarDel(req *types.CarDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.JdRpc.CarDel(l.ctx, &jdclient.CarDelRequest{
		GoodsId: int64(req.GoodsId),
		UserId:  int64(req.UserId),
	})
	if err != nil {
		return &types.Response{
			Code: 200,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "移除成功",
		Data: add,
	}, nil
}
